const db = require('./db');

function Music(title, singer, time, file, filelrc, uid) {
    this.title = title;
    this.singer = singer;
    this.time = time;
    this.file = file;
    this.filelrc = filelrc;
    this.uid = uid;
}

Music.addMusic = async singObj => await db.query('insert into musics(title, singer, time, file, filelrc, uid) values(?,?,?,?,?,?)', Object.values(singObj));
Music.updateMusic = async singObj => await db.query('update musics set title=?,singer=?,time=?,file=?,filelrc=?,uid=? where id=?', Object.values(singObj));
Music.deleteMusicByID = async id => await db.query('delete from musics where id=?', [id]);
Music.findMusicByID = async id => await db.query('select * from musics where id=?', [id]);
Music.findMusicByUid = async uid => await db.query('select * from musics where uid=?', [uid]);

module.exports = Music;